package it.fuesi.synoutils.model.download;

import java.io.Serializable;

import it.fuesi.synoutils.model.base.IModel;

/**
 * Created by pascotto on 16/10/14.
 */
public class DownloadTask implements Serializable, IModel {




    public static enum TaskStatus{
        waiting,
        downloading,
        paused,
        finishing,
        finished,
        hash_checking,
        seeding,
        filehosting_waiting,
        extracting,
        error
    }

    private String id;
    private long size;
    private String status;
    //private String status_extra;
    private String title;
    private String type;
    private String username;

    public DownloadTaskAdditional getAdditional() {
        return additional;
    }

    public void setAdditional(DownloadTaskAdditional additional) {
        this.additional = additional;
    }

    private DownloadTaskAdditional additional;


    public int getDownloadPercent(){
        final long downloaded = getAdditional().getTransfer().getSize_downloaded();
        if(downloaded == 0) return 0;

        if(downloaded >= size) return 100;

        if(size == 0) return 0;

        return (int)((double)((double)100/(double)size) * downloaded);
    }

    public TaskStatus getTaskStatus(){
        return TaskStatus.valueOf(status);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    /*
    public String getStatus_extra() {
        return status_extra;
    }

    public void setStatus_extra(String status_extra) {
        this.status_extra = status_extra;
    }*/

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
